package com.jzo2o.market.controller.operation;

import com.jzo2o.common.model.PageResult;
import com.jzo2o.market.model.dto.request.ActivityQueryForPageReqDTO;
import com.jzo2o.market.model.dto.request.ActivitySaveReqDTO;
import com.jzo2o.market.model.dto.response.ActivityInfoResDTO;
import com.jzo2o.market.service.IActivityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * TODO
 *
 * @Author lyh
 * @Date 2024/12/14 18:04
 */
@RestController("operationActivityController")
@RequestMapping("/operation/activity")
@Api(tags = "管理端 - 优惠券活动相关接口")
public class ActivityController {
    @Autowired
    private IActivityService activityService;
   @PostMapping("/save")
   @ApiOperation("新增或修改一个优惠券活动信息")
   public void saveActivity(@RequestBody ActivitySaveReqDTO dto){
       activityService.saveActivity(dto);
   }
   @GetMapping("/page")
   @ApiOperation("分页查询优惠券活动接口")
   public PageResult<ActivityInfoResDTO> pageQuery(ActivityQueryForPageReqDTO dto){
      return activityService.pageQuery(dto);
   }
   @GetMapping("/{id}")
   public ActivityInfoResDTO getById(@PathVariable Long id){
       return activityService.getActivityById(id);
   }
   @PostMapping("/revoke/{id}")
   @ApiOperation("撤销活动")
   public void revokeActivity(@PathVariable Long id){
       activityService.revokeActivity(id);
   }
}
